<template>
  <div>
    <div @keyup.enter="getData()">
      <el-form class="query-table-form" :inline="true">
        <el-form-item>
          <el-input v-model="params.customer_name" placeholder="项目名称查询" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="params.corp_name"
            placeholder="负责人查询"
            :clearable="true"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <select-address
            v-model="params.address_code"
            clearable
            placeholder="地址查询"
            :auto-top="true"
            @change="getData()"
          ></select-address>
        </el-form-item>
        <!-- <el-form-item>
          <c-select v-model="params.task_status"
                    clearable
                    @change="getData"
                    placeholder="档案卡状态"
                    :options="creditStatus"></c-select>
        </el-form-item> -->
        <el-form-item>
          <el-button @click="getData()">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="exportExcel('建档任务列表')" :loading="exportLoading">导出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <c-table
      border
      v-loading="loading"
      :stripe="false"
      :columns="tableColumns"
      :data="tableData"
      height="76vh"
    ></c-table>

    <div class="query-pagination">
      <div></div>
      <el-pagination
        layout="total, prev, pager, next, jumper"
        :current-page.sync="params.index"
        :page-size="params.size"
        :total="totalCount"
        @current-change="getData"
      ></el-pagination>
    </div>

    <el-dialog
      :visible.sync="reportVisible"
      :close-on-click-modal="false"
      :before-close="handleCreditClose"
      append-to-body
      top="30px"
      width="80%"
    >
      <credit-file :query-id="queryId" @success="handleEditSuccess"></credit-file>
    </el-dialog>
  </div>
</template>
<script>
import CreditFile from '@/gov/components/creditFile/GovCredit'
import { enumProjectType } from '@/gov/plugins/enum'
import taskTableMixin from '@/credit/mixin/task/taskTable'
import SelectAddress from '@/components/select/SelectAddress'
export default {
  components: {
    CreditFile,
    SelectAddress,
  },
  mixins: [taskTableMixin],
  props: {},
  data() {
    return {
      enumProjectType,
      loading: false,
      order: { N1archive_complete_time: 'desc' },
      // creditStatus: { 0: '未建档', 1: '已建档' },
      params: {
        index: 1,
        size: 10,
        'submit_type.eq': 1,
      },
      tableData: [],
      tableColumns: [
        { attrs: { label: '未建档主体', prop: 'customer_name', align: 'center' } },
        { attrs: { label: '地址', prop: 'address', align: 'center' } },
        { attrs: { label: '负责人', prop: 'corp_name', align: 'center' } },
        { attrs: { label: '联系电话', prop: 'mobile_no', align: 'center' } },
        { attrs: { label: '项目类型', prop: 'project_type_label', align: 'center' } },
        { attrs: { label: '项目状态', prop: 'statusLabel', align: 'center' } },
        {
          attrs: { label: '操作', align: 'center' },
          operations: [
            {
              name: '档案卡',
              event: this.handleEdit,
            },
          ],
        },
      ],

      reportVisible: false,
      queryId: '',
    }
  },
  computed: {},
  watch: {
    visible() {
      if (this.visible) {
        this.getData()
      }
    },
  },
  created() {
    this.params.address_code = this.$utils.getAddressCode()
    this.params['task_status.eq'] = this.status
    this.params['task_type.eq'] = this.type
  },
  mounted() {},
  methods: {
    getParams() {
      return this.params
    },
    getTabData() {
      this.getData()
    },
    beforeClose() {
      this.$emit('update:visible', false)
    },
    handleEdit(row) {
      this.queryId = row.customer_related_id
      this.reportVisible = true
    },
    dataAdapter(item) {
      item.statusLabel = +item.task_status === 0 ? '未建档' : '已建档'
      item.project_type_label = enumProjectType[+item.project_type] || '-'
      return item
    },
    handleCreditClose() {
      this.reportVisible = false
      this.getData(this.params.index)
    },
    handleEditSuccess() {
      this.reportVisible = false
      this.$store.dispatch('getMyTaskCount')
      this.$emit('success', true)
    },
  },
}
</script>
<style lang="scss" scoped></style>
